package me.pearjelly.dao.hibernate;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import me.pearjelly.dao.CrawlerDao;
import me.pearjelly.model.Crawler;

@Repository
public class CrawlerDaoImpl extends AbstractDao implements CrawlerDao {
	@SuppressWarnings("unchecked")
	@Override
	public List<Crawler> findAll() {
		try {
			return (List<Crawler>) getHibernateTemplate().find("from Crawler");
		} catch (DataAccessException e) {
			logger.error(e.getMessage());
			throw e;
		}
	}

	public void saveOrUpdate(Crawler crawler) {
		try {
			getHibernateTemplate().saveOrUpdate(crawler);
		} catch (DataAccessException e) {
			logger.error(e.getMessage());
			throw e;
		}
	}

	private static final Logger logger = LoggerFactory
			.getLogger(PicDaoImpl.class);
}
